


/*改变一级菜单*/
function changeFirstMenu($this) {
    $($this).addClass('active').siblings('li').removeClass('active');
    schoolArea = $($this).attr("data-code");
    getSchoolList();
}


/**
 * 根据父级菜单编号，获取子菜单集合
 */
function getSecondMenuList(parentNo, streetNo) {
    var noDataHtml = "<img src='"+ctx+"img/school-district/not-data.png"+"'/>";
    $.showLoading("数据加载中");
    $.ajax({
        type: 'post',
        url: prefix + '/getSecondMenuOptions',
        data: {
            "parentNo": parentNo,
            "streetNo": streetNo,
            "content" : content
        },
        dataType: 'json',
        success: function (data) {
            if (data.code === 200) {
                if (data.data && data.data.length > 0 ) {
                    initSecondMenu(data.data);
                }else {
                    $("#context").html("").html("<div class='noContext'>暂无数据</div>");
                }
            } else {
                $("#context").html("").html("<div class='noContext'>暂无数据</div>");
            }
            $.hideLoading();
        },
        error: function () {
            $("#context").html("").html("<div class='noContext'>暂无数据</div>");
            $.hideLoading();
        }
    });
}

/**
 * 渲染学校集合
 * @param obj
 */
function initSchoolList(obj) {
    var $child = "";
    for (var j = 0; j < obj.length; j++) {
        $child += buildItem(obj[j]);
    }
    $("#context").html("").html($child);
}


/**
 * 渲染单条学校信息
 * @param data
 * @returns {string}
 */
function buildItem(data) {
    var html = "<div class=\"weui-media-box weui-media-box_appmsg\">" +
        "                <div class=\"weui-media-box__hd\">" +
        "                    <img class=\"weui-media-box__thumb imgMiddle\" src='"+ctx+"img/school-district/school-icon.png"+"' alt=\"\">" +
        "                </div>" +
        "                <div class=\"weui-media-box__bd\" sid='"+data.sid+"' onclick='viedSchoolDetail(this)'>" +
        // "                    <a class=\"hrefzzgx\" typeNo=\"" + data.workNo + "\" onclick=\"getwechtMaticlSkip(this)\">" +
        "                        <h4 class=\"weui-media-box__title takenItem_class\">" + data.schoolName + "</h4>" +
        // "                    </a>" +
        /*        "                    <p class=\"weui-media-box__desc\"><a typeNo='" + data.workNo + "' onclick='dealTodo(this)'>我要办理</a></p>" +
                "                    <div class=\"xuxian\"></div>" +
                "                    <p class=\"weui-media-box__desc\"><a class=\"blpjBtn\" typeNo='" + data.workNo + "' onclick='dealHis(this)'>进展查询</a></p>" +*/
        "                </div>" +
        "                <a class=\"weui-cell weui-cell_access\" href=\"javascript:;\" sid='"+data.sid+"' onclick='getwechtMaticlSkip(this)'>" +
        "                    <div class=\"weui-cell__ft\">" +
        "                    </div>" +
        "                </a>" +
        "       </div>";
    html += "<div class=\"typeSpace\"></div>";
    return html;
}

/**
 * 办理详情
 * @param me
 */
function getwechtMaticlSkip(obj) {
    var code = $(obj).attr("typeNo");
    var title = $(obj).attr("typeName");
    window.location.href = ctx + "wechat/process/details?code=" + code+"&title="+title + "&streetNo="+$street+"&content="+content+"&type="+$type;
}


/**
 * 查看学校详情
 */
function viedSchoolDetail(dom){

    var sid = $(this).attr("sid");

    console.log(sid);

}


/** 清除搜索内容*/
$("#searchClear").on("click",function () {
    content = '';
    getSchoolList();
});

$("#searchInput").on("input",function () {
    
    content = $.trim($("#searchInput").val());
    if( content && content !="") {
        //输入框有值，根据内容查询二级菜单项
        getSchoolList();
    }else {
        //输入框已清除，查询当前大类型和街道的二级菜单
        getSchoolList();
    }

});

